package com.tianhao.luo.v2.use;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Random;

/**
 * @ClassName: Wizard
 * @Description: 使用迪米特法则的安装步骤
 * @author: tianhao.luo@hand-china.com
 * @date: 2020/7/14  17:26
 */
public class Wizard {

    private Random rand = new Random(System.currentTimeMillis());
    private static final Logger LOGGER = LoggerFactory.getLogger(com.tianhao.luo.v2.Wizard.class);

    private int first() {
        LOGGER.info("执行第一个方法");
        return rand.nextInt(100);
    }

    private int second() {
        LOGGER.info("执行第二个方法");
        return rand.nextInt(100);
    }

    private int third() {
        LOGGER.info("执行第三个方法");
        return rand.nextInt(100);
    }

    public void installWizard() {
        int first = this.first();
        //根据first返回的结果，看是否需要执行second
        if (first>50){
            int second = this.second();
            if (second>50){
                int third = this.third();
                if (third>50){
                    this.first();
                }
            }
        }
    }
}
